#@layout()

#define script()
<script>

    $("#sync").on("click", function () {
        ajaxGet("#(CPATH)/admin/permission/syncPermissions",
            function (result) {
                toastr.options.onHidden = function () {
                    location.reload();
                }
                toastr.success(result.message);
            },
            function (result) {
                toastr.success(result.message);
            }
        )
    });


    var type = getPara("type");
    if ("menu" == type) {
        $("#group-menu").addClass("active");
    } else if ("action" == type) {
        $("#group-action").addClass("active");
    } else {
        $("#group-all").addClass("active");
    }


</script>
#end

#define css()
<style>
    .switchery-small {
        margin-top: 0px;
    }
</style>
#end

#define content()

    <section class="content-header">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-6">

                    <div class="row mb-2">
                        <div class="col-sm-12">
                            <h1>
                                用户权限
                                <small data-toggle="tooltip" title="" data-placement="right"
                                       data-trigger="hover"><i class="nav-icon far fa-question-circle"></i></small>
                                <small> 首页 / 用户 / 用户权限</small>
                            </h1>
                        </div>
                    </div>
                </div>

            </div>

        </div><!-- /.container-fluid -->
    </section>




    <section class="content">

        <div class="container-fluid">
                <div class="card card-outline card-primary">

                    <div class="card-header  ">
                        <div class="admin-search-panel">
                            <div class="col-12">
                                <div class="btn-group">
                                    <a href="#(CPATH)/admin/permission/list" id="group-all" class="btn btn-default">全部</a>
                                    <a href="#(CPATH)/admin/permission/list?type=menu" id="group-menu"
                                       class="btn btn-default">菜单</a>
                                    <a href="#(CPATH)/admin/permission/list?type=action" id="group-action"
                                       class="btn btn-default">URL</a>
                                </div>

                                <button type="button" class="btn btn-primary float-right" id="sync">
                                    <i class="fa fa-fw fa-exchange-alt"></i>同步所有权限
                                </button>
                            </div>
                        </div>
                    </div>
                    <!-- /.card-header -->
                    <div class="card-body waterfall-container" style="
                    -moz-column-count: 2;
                    -webkit-column-count: 2;
                    column-count: 2;
                    -moz-column-gap: 1em;
                    -webkit-column-gap: 1em;
                    column-gap: 1em;">

                        #for(x : permissionGroup)
                        <div class="waterfall-item" style="
                        -webkit-column-break-inside: avoid;
                        break-inside: avoid;
                        position: relative;

        box-sizing: border-box;

                            ">
                            <div class="card card-outline card-dashboard">
                                <div class="card-header with-border">
                                    <h3 class="card-title">#(x.key ??)</h3>
                                </div>
                                <!-- /.card-header -->
                                <div class="card-body p-0">
                                    <table class="table table-striped">
                                        <tbody>
                                        <tr>
                                            <th>ActionKey</th>
                                            <th>描述</th>
                                            <th style="width: 80px">类型</th>
                                        </tr>
                                        #for(permission : x.value)
                                        <tr>
                                            <td>#(permission.action_key ??)</td>
                                            <td>#(permission.text ??)</td>
                                            <td>#(permission.typeText ??)</td>
                                        </tr>
                                        #end
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        #end

                    </div>
                </div>
            </div>


    </section>
#end
